<?php if (! $this->_tpl_vars['Editor']->GetReadOnly()): ?>
<?php if ($this->_tpl_vars['RenderText']): ?>
<textarea
    data-editor="true"
    data-editor-class="HtmlEditor"
    data-field-name="<?php echo $this->_tpl_vars['Editor']->GetFieldName(); ?>
"
    data-editable="true"

    class="html_wysiwyg"
    id="<?php echo $this->_tpl_vars['Editor']->GetName(); ?>
"
    name="<?php echo $this->_tpl_vars['Editor']->GetName(); ?>
"
    <?php echo $this->_tpl_vars['Validators']['InputAttributes']; ?>
>
<?php echo $this->_tpl_vars['Editor']->GetValue(); ?>

</textarea>
<?php endif; ?>
<?php if ($this->_tpl_vars['RenderScripts']): ?>
<?php if ($this->_tpl_vars['RenderText']): ?>
<script type="text/javascript">
<?php echo '

$(function(){
    window.setTimeout(function()
    {

'; ?>

<?php endif; ?>

<?php echo '
require(PhpGen.ModuleList([PhpGen.Module.TinyMCE, PhpGen.Module.PG.Editors]), function() {
'; ?>


    $('#<?php echo $this->_tpl_vars['Editor']->GetName(); ?>
').tinymce({
        script_url : 'libs/jquery/tiny_mce/tiny_mce.js',
        theme : "advanced",

        theme_advanced_buttons1 :
            "bold,italic,underline,strikethrough" + ",|," +
            "justifyleft,justifycenter,justifyright,justifyfull" + ",|," +
            "styleselect,formatselect,fontselect,fontsizeselect",

        theme_advanced_buttons2 :
            "bullist,numlist" + ",|," +
            "outdent,indent,blockquote" + ",|," +
            "undo,redo" + ",|," +
            "link,unlink,anchor,image,cleanup,help,code",

        theme_advanced_buttons3 :
            <?php if ($this->_tpl_vars['Editor']->GetAllowColorControls()): ?>
            "forecolor,backcolor" + ",|," +
            <?php endif; ?>
            "hr,removeformat,visualaid" +  ",|," +
            "sub,sup" + ",|," +
            "charmap",

        onchange_callback: function() { PhpGen.htmlEditorGlobalNotifier.valueChanged("<?php echo $this->_tpl_vars['Editor']->GetFieldName(); ?>
"); },
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "left",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : true
       });

<?php echo '
});
'; ?>


<?php if ($this->_tpl_vars['RenderText']): ?>
<?php echo '
    }, 10);
});
'; ?>

</script>
<?php endif; ?>
<?php endif; ?>
<?php else: ?>
<?php if ($this->_tpl_vars['RenderText']): ?>
<span
    data-editor="true"
    data-editor-class="HtmlEditor"
    data-field-name="<?php echo $this->_tpl_vars['Editor']->GetFieldName(); ?>
"
    data-editable="false">
<?php echo $this->_tpl_vars['Editor']->GetValue(); ?>

</span>
<?php endif; ?>
<?php endif; ?>